//
//  FNBannerCollectionViewCell1.swift
//  FNBanner
//
//  Created by Fnoz on 2016/10/29.
//  Copyright © 2016年 Fnoz. All rights reserved.
//

import Kingfisher

let incline = CGFloat(1.5)
let interval = CGFloat(1)

class FNBannerCollectionViewCell1: FNBannerCollectionViewBaseCell {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        contentView.addSubview(bannerImageView)
        bannerImageView.contentMode = .scaleAspectFill
        bannerImageView.layer.masksToBounds = true
        
        bannerImageView.snp.makeConstraints { (make) in
            make.width.equalTo(contentView.bounds.width)
            make.height.equalTo(contentView)
            make.center.equalTo(contentView)
        }
        
        let bezierPath = UIBezierPath.init();
        bezierPath.move(to: CGPoint.init(x: 0 + interval * 0.5, y: 0))
        bezierPath.addLine(to: CGPoint.init(x: frame.width / incline - interval * 0.5, y: 0))
        bezierPath.addLine(to: CGPoint.init(x: frame.width - interval * 0.5, y: frame.height))
        bezierPath.addLine(to: CGPoint.init(x: frame.width / incline * (incline - 1) + interval * 0.5, y: frame.height))
        bezierPath.addLine(to: CGPoint.init(x: 0 + interval * 0.5, y: 0))
        bezierPath.close()
        let maskLayer = CAShapeLayer.init()
        maskLayer.path = bezierPath.cgPath
        bannerImageView.layer.mask = maskLayer
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
